﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace InterfaceFiles
{
  public class XPSWMM10InterfaceHeader : BaseInterfaceHeader, IInterfaceHeader
  {
    public XPSWMM10InterfaceHeader(IInterfaceReader reader)
      : base(reader)
    {
    }

    #region IInterfaceHeader Implementation

    public override void Read()
    {
      string title1 = ReadTitle();
      string title2 = ReadTitle();
      int startJulDateAsInt = ReadJulianDate();
      JulianDate startJulDate = new JulianDate(startJulDateAsInt);
      double startSecondsOfDay = ReadSecondsOfDay();
      string title3 = ReadTitle();
      string title4 = ReadTitle();
      string sourceBlock = ReadSourceBlock();
      int numNodes = ReadNumNodes();
      int numPollutants = ReadNumPollutants();
      double area_sqft = ReadAreaSqFt();

      Titles.Clear();

      Titles.Add(title1);
      Titles.Add(title2);

      DateTime startDate = (DateTime)startJulDate;
      StartTime = startDate.AddSeconds(startSecondsOfDay);
          
      Titles.Add(title3);
      Titles.Add(title4);

      SourceBlock = sourceBlock;
      NumNodes = numNodes;
      NumPollutants = numPollutants;
      // XP-SWMM always specifies negative area here
      Area_sqft = -area_sqft;
      // XP-SWMM always uses alphanumeric IDs
      UseAlphaNumIDs = true;

      Nodes.Clear();
      for (int i = 0; i < NumNodes; i++)
      {
        string node = ReadNode();
        Nodes.Add(node);
      }

      FlowMultiplier = ReadFlowMultiplier();
    }

    #endregion
  }
}
